package com.bigdatastudio.admin.controller;

import com.bigdatastudio.auth.server.IAuthService;
import com.bigdatastudio.common.Utils.R;
import com.bigdatastudio.common.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xiao_jie
 * @since 2022-09-12
 */
@RestController
@RequestMapping("/user")
public class AuthController {

    @Autowired
    private IAuthService service;


    // 登录
    @CrossOrigin("true")
    @PostMapping("/login")
    public R userLogin(@RequestBody User user, HttpServletRequest request) {
        return service.userLogin(user, request);
    }

    // 退出
    @GetMapping("/logout")
    public R userLogout(HttpServletRequest request) {
        String token = request.getHeader("token");
        return service.userLogOut(token);
    }

}
